package com.base.string;

/**
 * @author leon
 * @Description: TODO
 * @date 2022年04月07日 15:34
 */
public class RotateString {
    public boolean rotateString(String s, String goal) {
        if (s == null || goal == null || s.length() != goal.length()) {
            return false;
        }
        char[] cs = s.toCharArray();
        char[] cg = goal.toCharArray();
        for (int i = 0; i < cs.length; i++) {
            int j = i;
            int k = 0;
            for (; k <cg.length&&cs[j%cs.length]==cg[k]; k++) {
                j++;
            }
            if (k == cg.length) {
                return true;
            }
        }
        return false;
    }
}
